<!DOCTYPE html>
<html>
<head>
    <title>PlayCanvas Model Shapes</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="icon" type="image/png" href="../playcanvas-favicon.png" />
    <script src="../../build/output/playcanvas.js"></script>
    <style>
        body { 
            margin: 0;
            overflow-y: hidden;
        }
    </style>
</head>

<body>
    <!-- The canvas element -->
    <canvas id="application-canvas"></canvas>

    <!-- The script -->
    <script>
        var canvas = document.getElementById("application-canvas");

        // Create the application and start the update loop
        var app = new pc.Application(canvas);
        app.start();

        // Set the canvas to fill the window and automatically change resolution to be the same as the canvas size
        app.setCanvasFillMode(pc.FILLMODE_FILL_WINDOW);
        app.setCanvasResolution(pc.RESOLUTION_AUTO);

        window.addEventListener("resize", function () {
            app.resizeCanvas(canvas.width, canvas.height);
        });

        // All model component primitive shape types
        var shapes = [ "box", "plane", "cone", "cylinder", "sphere", "capsule" ];
        var x = -1, y = -1;

        shapes.forEach(function (shape) {
            // Create an entity with a model component
            var entity = new pc.Entity();
            entity.addComponent("model", {
                type: shape
            });
            app.root.addChild(entity);

            // Lay out the 6 primitives in two rows, 3 per row
            entity.setLocalPosition(x * 1.2, y, 0);
            if (x++ === 1) {
                x = -1;
                y = 1;
            }
        });

        // Create an entity with a directional light component
        var light = new pc.Entity();
        light.addComponent("light", {
            type: "directional"
        });
        app.root.addChild(light);
        light.setLocalEulerAngles(45, 30, 0);

        // Create an entity with a camera component
        var camera = new pc.Entity();
        camera.addComponent("camera", {
            clearColor: new pc.Color(0.4, 0.45, 0.5)
        });
        app.root.addChild(camera);
        camera.setLocalPosition(0, 0, 5);
    </script>
</body>
</html>
